/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImageLoad.java
 *
 * Created on 14/09/2010, 04:16:26 PM
 */
package LookAndFeel.Gui.Imag;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

/**
 *
 * @author killan
 */
public class ImageLoad extends javax.swing.JPanel {

    /** Creates new form ImageLoad */
    private java.awt.Image img;
    private BufferedReader in;

    public ImageLoad() {
        initComponents();
    }

    public static void setImageinImagePanel(Image imagen, ImageLoad panel) {
        JPanelImage paneldeImagen = panel.jPanelImage1;
        paneldeImagen.setImage(null);
        paneldeImagen.setImage(imagen);
    }//fin método: setImageinImagePanel

    public static void setImageinImagePanel(String path, ImageLoad panel) {
        JPanelImage paneldeImagen = panel.jPanelImage1;
        try {
            paneldeImagen.setBackground(path);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    Image getImagen(String url) {
        Image imagen;
        BufferedImage bufferedImage = null;
        //Realizamos la lectura del archivo.
        File archivo = new File(url);
        System.out.println(" " + archivo);
        try {
            bufferedImage = (ImageIO.read(archivo));
        } catch (IOException ex) {
            Logger.getLogger(ImageLoad.class.getName()).log(Level.SEVERE, null, ex);
        }
        imagen = bufferedImage;
        return imagen;
    }//fin mètodo: getImagen()..

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelImage1 = new LookAndFeel.Gui.Imag.JPanelImage();

        setBackground(new java.awt.Color(255, 255, 255));

        jPanelImage1.setBackground(new java.awt.Color(51, 51, 255));
        jPanelImage1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jPanelImage1Layout = new javax.swing.GroupLayout(jPanelImage1);
        jPanelImage1.setLayout(jPanelImage1Layout);
        jPanelImage1Layout.setHorizontalGroup(
            jPanelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 267, Short.MAX_VALUE)
        );
        jPanelImage1Layout.setVerticalGroup(
            jPanelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 365, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private LookAndFeel.Gui.Imag.JPanelImage jPanelImage1;
    // End of variables declaration//GEN-END:variables
}
